import SDKAdatper from "../core/SDKAdatper";
import RecorderAdapter from "../core/RecorderAdapter";
import AdAdapter from "../core/AdAdapter";

class KSRecorderAdapter extends RecorderAdapter {

    publish(param?: any) {
        this._recorder.publishVideo(param)
    }
    onStart(func: Function) {
        this._recorder.on('start', func)
    }
    onStop(func: Function) {
        this._recorder.on('stop', func)
    }
    onResume(func: Function) {
        this._recorder.on('resume', func)
    }
    onPause(func: Function) {
        this._recorder.on('pause', func)
    }
    onError(func: Function) {
        this._recorder.on('error', func)
    }


}

export class KSRewardAd extends AdAdapter {
    load() {
        if (this._ad.load)
            return this._ad.load();
    }
}

export default class KSSDK extends SDKAdatper {

    hasRecorder() {
        return this.hasSDK() && this._sdk.getGameRecorder
    }


    getGameRecorderManager() {
        if (this.hasRecorder()) {
            return new KSRecorderAdapter(this._sdk.getGameRecorder());
        }
        return null;
    }
}